fix(site): reject a --proxy port outside 1-65535 instead of silently misconfiguring - #280
Merged
ralyodio merged 1 commit intoAug 3, 2026
Conversation
…misconfiguring `moshcode site <name> --proxy <port>` validated the port with `^\d+$`, which accepts 0 and out-of-range numbers. --proxy 0 is falsy downstream, so the site silently dropped to a static root; --proxy 99999 wrote a proxy_pass to a port that cannot exist. Both exited 0 and reported the site as live. Validate the port as 1-65535, matching the range every other port takes here (console --port, dns --port/--parking-port). Adds a regression test plus a control that a real port still installs the reverse proxy unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Merged
ralyodio
added a commit
that referenced
this pull request
Aug 4, 2026
A Moshpit name now survives the TLS handshake without a per-name detour. `dns trust <name>` installs the leaf a name serves, but only when its key matches a pin the registry already published, and `dns start --trust-all` does that as names resolve (#279, #281). Minor, not patch: two new ways to invoke the tool. Also carries two commands that used to report success they had not earned -- `update --timer --install` when systemctl refused (#282), and `site --proxy` with a port outside 1-65535 (#280). Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
moshcode site <name> --proxy <port>validated the port with/^\d+$/. That accepts0and out-of-range numbers, and both then fail silently:--proxy 0passes the regex, but0is falsy downstream, soservePlanbuilds a static root server, not a reverse proxy. It reports the site as live.--proxy 99999passes the regex and writesproxy_pass http://127.0.0.1:99999;— a port that cannot exist. It also reports the site as live.Every other port in the codebase is validated as 1-65535 (
console --port,dns --port,dns --parking-port, all with the messageneeds a decimal integer from 1 to 65535).--proxywas the odd one out.Before (unmodified main)
Driving the exported
serveCommandwith a stubbed writer:After
Change
src/serve.mjs: validate--proxyas an integer in 1-65535, with the same message style the rest of the CLI uses.test/serve.test.mjs: a regression test that0,99999,70000,-1,abcand empty are refused with exit 1 and no config written, plus a control asserting a real port still installs the reverse proxy unchanged.Full suite: 1214 tests, 1001 pass, 0 fail (1000→1001, one new test). No other files touched.